﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ProgNetComponentsDx.Browsers;
using System.Data;
using ProgNetComponentsDx.Language;
using ProgNetComponents.Design.Attributes;
using System.ComponentModel;

namespace ProgNetComponentsDx.Validation.Rules
{
    public class BrowserValueValidationRule : BrowserValidationRule
    {
        #region Static
        static BrowserValueValidationRule()
        {
            GlobalDefaultErrorString = "Ta wartość jest nieprawidłowa.";
        }
        public static string GlobalDefaultErrorString { get; set; }
        #endregion


        protected override string DefaultErrorString
        {
            get
            {
                return GlobalDefaultErrorString;
            }
        }
        public BrowserValueValidationRule() { }
        public BrowserValueValidationRule(string column, object browserId, string error = null)
            : base(column, browserId, error)
        {
            
        }

        protected override bool DoValidate(DataRow row)
        {
            return IsValueValid(row);
        }

    }

    public class BrowserValueValidationRuleLng : BrowserValueValidationRule
    {
        #region Static
        static BrowserValueValidationRuleLng()
        {
            GlobalDefaultErrorStringNoLng = "Wartość z pola [{0}] jest nieprawidłowa.";
        }
        public static string GlobalDefaultErrorStringLng { get; set; }
        public static string GlobalDefaultErrorStringNoLng { get; set; }
        #endregion

        protected override string DefaultErrorString
        {
            get
            {
                return GlobalDefaultErrorStringLng;
            }
        }
       
        /// <summary>
        /// Gets formatted error string
        /// </summary>
        public override string FormatedErrorString
        {
            get
            {
                string str = ProgNetLanguage.sGetStringDefault(ErrorString, GlobalDefaultErrorStringNoLng, ProgNetLanguage.sGetStringDefault(Column, Column));
                return str;
            }
        }
        public BrowserValueValidationRuleLng() { }
        public BrowserValueValidationRuleLng(string column, object browserId, string error = null)
            : base(column, browserId, error)
        {

        }
    }
}
